﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.QueryEntity;

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall), AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class CommonMethodService : ICommonMethodService
    {
        public string AuditContractByContractID(List<string> contractID, string audit, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new CommonMethodBLL(pubParasInfo).AuditContractByContractID(contractID, audit);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return result;
        }

        public string CreatedLocation(CreatedLocationinfo CreateLocation, LocationInfo Location, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
                return commonMethod.CreatedLocation(CreateLocation, Location);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BaseInfoDetailService异常");
            }
            return "";
        }

        public string DeleteCustGridviewInfos(string functionID, string gridviewID, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.DeleteCustGridviewInfos(functionID, gridviewID);
        }

        public List<AppSettingInfo> GetAllAppSettingInfo()
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL();
            return commonMethod.GetAllAppSettingInfo();
        }

        public List<VisualLocationInfo> GetAllVisualLocationInfo(VisualLocationQueryEntity VisualLocQuery, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetAllVisualLocationInfo(VisualLocQuery);
        }

        public AppRegInfo GetAppRegInfo(PubParasInfo pubParasInfo)
        {
            try
            {
                AppRegBLL appReg = new AppRegBLL(pubParasInfo);
                return appReg.GetAppRegInfo();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return null;
        }

        public LotTemplateInfo GetAttributeInfoBySkuID(string SkuID, string OwnerID, PubParasInfo pubParasInfo)
        {
            LotTemplateInfo lotTemplate = new LotTemplateInfo();
            try
            {
                lotTemplate = new CommonMethodBLL(pubParasInfo).GetAttributeInfoBySkuID(SkuID, OwnerID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return lotTemplate;
        }

        public DataSet GetAuthorizationUserByType(string Type, string entityID, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethodBLL = new CommonMethodBLL(pubParasInfo);
                return commonMethodBLL.GetAuthorizationUserByType(Type, entityID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return null;
        }

        public List<OwnerInfo> GetAuthorizedOwnerByUserID(string userID, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethodBLL = new CommonMethodBLL(pubParasInfo);
                return commonMethodBLL.GetAuthorizedOwnerByUserID(userID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return null;
        }

        public decimal GetAvailableQty(string ownerID, string skuID, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetAvailableQty(ownerID, skuID);
        }

        public List<CartonGroup4DDL> GetCartonGroup4Select(PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetCartonGroup4Select();
        }

        public List<CustGridviewInfo> GetCustGridviewInfos(string functionID, string gridviewID, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetCustGridviewInfos(functionID, gridviewID);
        }

        public List<CycleCountRule4DDL> GetCycleCountRule4Select(PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetCycleCountRule4Select();
        }

        public List<FieldNameInfo> GetFieldNameByTableName(string TableName, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetFieldNameByTableName(TableName);
        }

        public DataSet GetInitGridViewInfoByQueryEntity(InitGridviewQueryEntity initGridviewQuery, PubParasInfo pubParasInfo)
        {
            DataSet ds = null;
            try
            {
                ds = new CommonMethodBLL(pubParasInfo).GetInitGridViewInfoByQueryEntity(initGridviewQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return ds;
        }

        public List<InitGridviewInfo> GetInitGridviewInfos(string functionID, string gridviewID, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetInitGridviewInfos(functionID, gridviewID);
        }

        public DataSet GetInvSkuQtyByOwnerID(string ownerID, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethodBLL = new CommonMethodBLL(pubParasInfo);
                return commonMethodBLL.GetInvSkuQtyByOwnerID(ownerID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return null;
        }

        public List<LotAttributeCodeInfo> GetLotAttributCodeByGroupID(string groupID, PubParasInfo pubParasInfo)
        {
            List<LotAttributeCodeInfo> lotAttributeCodeInfos = new List<LotAttributeCodeInfo>();
            try
            {
                lotAttributeCodeInfos = new CommonMethodBLL(pubParasInfo).GetLotAttributCodeByGroupID(groupID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return lotAttributeCodeInfos;
        }

        public List<string> GetLotAttributeCode4LotTemplate(PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetLotAttributeCode4LotTemplate();
        }

        public List<LotTemplate4DDL> GetLotTemplate4Select(PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetLotTemplate4Select();
        }

        public List<PreferenceValueInfo> GetPreferenceValueByID(string preferenceID)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL();
            return commonMethod.GetPreferenceValueByID(preferenceID);
        }

        public List<ReceiptValidation4DDL> GetReceiptValidation4Select(PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetReceiptValidation4Select();
        }

        public DataSet GetRelatedOrders(string Type, string skuID, string ownerID, string lot, string loc, string lpn, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethodBLL = new CommonMethodBLL(pubParasInfo);
                return commonMethodBLL.GetRelatedOrders(Type, skuID, ownerID, lot, loc, lpn);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return null;
        }

        public List<Rule4DDL> GetRules4Select(string ruleID, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetRules4Select(ruleID);
        }

        public DataSet GetShowGridviewInfo(string functionID, string gridviewID, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetShowGridviewInfo(functionID, gridviewID);
        }

        public SkuInfo GetSkuByBarcode(string Barcode, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetSkuByBarcode(Barcode);
        }

        public SkuInfo GetSkuInfoByUserOwner(string skuID, string userID, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethodBLL = new CommonMethodBLL(pubParasInfo);
                return commonMethodBLL.GetSkuInfoByUserOwner(skuID, userID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return null;
        }

        public List<SkuInfo> GetSkuInfosByOwnerIDAndBarCode(string ownerID, string barCode, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetSkuInfosByOwnerIDAndBarCode(ownerID, barCode);
        }

        public List<SysCode4DDL> GetSysCode4DDL(PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
                return commonMethod.GetSysCode4DDL();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return null;
        }

        public List<SysCode4DDL> GetSysCodeForDropDownList(string sysCodeType, string language, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetSysCodeForDropDownList(sysCodeType, language);
        }

        public List<UomList> GetUomListByPackID(string packID, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetUomListByPackID(packID);
        }

        public List<Owner4DDL> GetUserPermissionOwner(string userID)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL();
            return commonMethod.GetUserPermissionOwner(userID);
        }

        public List<WareHouseName4DDL> GetUserPermissionWareHouse(string userID)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL();
            return commonMethod.GetUserPermissionWareHouse(userID);
        }

        public List<WareHouseName4DDL> GetWareHouse4Select()
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL();
            return commonMethod.GetWareHouseName4Select();
        }

        public string ImportByData(string[][] ImportByData, string dataName, string IsUpdate, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethod = new CommonMethodBLL();
                return commonMethod.ImportByData(ImportByData, dataName, IsUpdate, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BaseInfoDetailService异常");
            }
            return "";
        }

        public string ImportByDataSet(DataSet ds, string dataName, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethod = new CommonMethodBLL();
                return commonMethod.ImportByDataSet(ds, dataName, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BaseInfoDetailService异常");
            }
            return "";
        }

        public string InsertCustGridviewInfos(List<CustGridviewInfo> custGridviewInfo, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.InsertCustGridviewInfos(custGridviewInfo);
        }

        public string LpnGenerateByGenerateType(LPNGenParams lpnGenParams, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethodBLL = new CommonMethodBLL(pubParasInfo);
                return commonMethodBLL.LpnGenerateByGenerateType(lpnGenParams);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return "";
        }

        public DataSet SearchDataByKey(string key, string key2, string Type, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
                return commonMethod.SearchDataByKey(key, key2, Type);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BaseInfoDetailService异常");
            }
            return null;
        }

        public string SqlAnalyse(string strSql, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.SqlAnalyse(strSql);
        }

        public DataSet SqlQuery(string sql, BaseQuery baseQuery)
        {
            try
            {
                CommonMethodBLL commonMethod = new CommonMethodBLL();
                return commonMethod.SqlQuery(sql, baseQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return null;
        }

        public string UpdateAuditDefinitionInfoByList(List<AuditDefinitionInfo> objs, PubParasInfo pubParasInfo)
        {
            AuditdefinitionBLL auditdefinitionBLL = new AuditdefinitionBLL(pubParasInfo);
            return auditdefinitionBLL.UpdateDetail(objs);
        }

        public int UpdateAuthorizationUserByType(string authorizationUser, string Type, string entityID, PubParasInfo pubParasInfo)
        {
            int result = 0;
            try
            {
                result = new CommonMethodBLL(pubParasInfo).UpdateAuthorizationUserByType(authorizationUser, Type, entityID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return result;
        }

        public string UpdateRegID(string regIDValue, PubParasInfo pubParasInfo)
        {
            try
            {
                AppRegBLL appReg = new AppRegBLL(pubParasInfo);
                return appReg.UpdateRegID(regIDValue);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return "";
        }

        public string UpdateUDF(string ID, UDFInfo udfInfo, string strType, PubParasInfo pubParasInfo)
        {
            try
            {
                CommonMethodBLL commonMethodBLL = new CommonMethodBLL(pubParasInfo);
                return commonMethodBLL.UpdateUDF(ID, udfInfo, strType);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return null;
        }
    }
}

